export function formatDate(date: Date, format: string) {
    const map = {
        'M': date.getMonth() + 1,
        'd': date.getDate(),
        'h': date.getHours(),
        'm': date.getMinutes(),
        's': date.getSeconds(),
        'y': date.getFullYear(),
    };
    format = format.replace(/([yMdhms])+/g, (all, single) => {
        const value = map[single];
        if (value !== undefined) {
            return single === 'y'
                ? value.toString().substr(4 - all.length)
                : value.toString().padStart(all.length, '0');
        }
        return all;
    });
    return format;
}